package top.kaoshanji.p2ch06b;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 代码清单 p2ch06b-03：UNICODE_CHARACTER_CLASS标记的使用的示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/17 19:50
 */
public class RegexExample03 {

    private static final Logger logger = LogManager.getLogger(RegexExample03.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p2ch06b-03：UNICODE_CHARACTER_CLASS标记的使用的示例...");

        String str = "100１００";
        Pattern pattern = Pattern.compile("(\\d+)");
        Matcher matcher = pattern.matcher(str);
        if (matcher.find()) {
            String digit = matcher.group(1);
            logger.info("...digit:{}...", digit);
        }

        pattern = Pattern.compile("(\\d+)", Pattern.UNICODE_CHARACTER_CLASS);
        matcher = pattern.matcher(str);
        if (matcher.find()) {
            String digit = matcher.group(1);
            logger.info("...digit:{}...", digit);
        }


    }

}
